import { onLoad, onShow } from "@dcloudio/uni-app";
import { ref } from "vue";
import { objectAny } from "../../options/base";
import {  myUserStore } from "../../store";
import { goToPage, showModal,hidePhoneNumber } from "../../utils/utils";

const userStore = myUserStore()

export default {
    setup() {

        // 用户基本信息包括仪表盘数据
        const userInfo = ref(userStore.myUser);

        onShow(async () => {
            // 获取用户的基本数据和身份信息
            userInfo.value=await userStore.getMyUserInfo()
        })

        // 账户切换按钮触发事件
        const typeShowModal = async () => {
            const status = await showModal({
                title: `切换账户`,
                content: `您确定需要重新身份？`
            });
            if (status) {
                goToPage({
                    path: `/common/mainEnter/mainEnter`,
                    navType: `replaceAll`
                });
            }
        }

        const goToShowUserInfo=()=>{
            goToPage({
                path:`/generalUser/userinfo/baseInfoSet`,
                navType:'push'
            })
        }

        async function noPermissions(content:string){
            await showModal({
                title: `操作提示`,
                content,
                showCancel:false
            });
        }


        return {
            userInfo,
            goToPage,
            typeShowModal,
            hidePhoneNumber,
            goToShowUserInfo,
            noPermissions
        }
    }
}